//
//  AccountHanler.m
//  time
//
//  Created by zuo on 15/4/1.
//  Copyright (c) 2015年 chenyirong007. All rights reserved.
//

#import "AccountHanler.h"
#import "UserDefaultsUtils.h"
#define kAppVersion  [[[NSBundle mainBundle] infoDictionary]    objectForKey:@"CFBundleShortVersionString"]
#define kLaunch [NSString stringWithFormat:@"%@isFirstLaunch",kAppVersion]

@implementation AccountHanler

/**< 是否是第一次启动 */
+ (BOOL)isFirstLaunch
{
    return [UserDefaultsUtils boolValueWithKey:kLaunch];
}
+ (void)saveIsFirstLaunch:(BOOL)isFirstLaunch
{
    [UserDefaultsUtils saveBoolValue:isFirstLaunch withKey:kLaunch];
}

/**< 系统本地版本 */
+ (NSString *)appLocalVersion
{
    NSString *strAppVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    return strAppVersion;
}

+ (NSString *)token
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_TOKEN];
}

+ (void)saveToken:(NSString *)token
{
    [UserDefaultsUtils saveValue:token forKey:SYSTEM_LOGIN_TOKEN];
}

+ (void)removeToken
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_TOKEN];
}

+ (BOOL)nowUsePackage
{
    return [UserDefaultsUtils boolValueWithKey:SYSTEM_LOGIN_NOWUSEPACKAGE];

}

+ (void)saveNowUsePackage:(BOOL)nowUsePackage
{
    [UserDefaultsUtils saveBoolValue:nowUsePackage withKey:SYSTEM_LOGIN_NOWUSEPACKAGE];
}

+ (void)removeNowUsePackage
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_NOWUSEPACKAGE];
}


+ (NSString *)idcardNo
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_IDCARDNO];
}

+ (void)saveIdcardNo:(NSString *)idcardNo
{
    [UserDefaultsUtils saveValue:idcardNo forKey:SYSTEM_LOGIN_IDCARDNO];
}

+ (void)removeIdcardNo
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_IDCARDNO];
}

+ (NSString *)username
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_USERNAME];
}

+ (void)saveUsername:(NSString *)username
{
    [UserDefaultsUtils saveValue:username forKey:SYSTEM_LOGIN_USERNAME];
}

+ (void)removeUsername
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_USERNAME];
}

+ (NSString *)telPhone
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_TELPHONE];
}

+ (void)saveTelPhone:(NSString *)telPhone
{
    [UserDefaultsUtils saveValue:telPhone forKey:SYSTEM_LOGIN_TELPHONE];
}

+ (void)removeTelPhone
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_TELPHONE];
}

+ (NSString *)sex
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_SEX];

}

+ (void)saveSex:(NSString *)sex
{
    [UserDefaultsUtils saveValue:sex forKey:SYSTEM_LOGIN_SEX];
}

+ (void)removeSex
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_SEX];
}

+ (NSString *)nickName
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_NICKNAME];
}

+ (void)saveNickName:(NSString *)nickName
{
    [UserDefaultsUtils saveValue:nickName forKey:SYSTEM_LOGIN_NICKNAME];
}

+ (void)removeNickName
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_NICKNAME];
}

+ (NSString *)personalizedSignature
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_SIGNATURE];
}

+ (void)savePersonalizedSignature:(NSString *)personalizedSignature
{
    [UserDefaultsUtils saveValue:personalizedSignature forKey:SYSTEM_LOGIN_SIGNATURE];
}

+ (void)removePersonalizedSignature
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_SIGNATURE];
}

+ (NSString *)packageList
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_PACKAGES];
}

+ (void)savePackageList:(NSString *)packages
{
    [UserDefaultsUtils saveValue:packages forKey:SYSTEM_LOGIN_PACKAGES];

}

+ (NSString *)pwd
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_PWD];
}

+ (void)savePwd:(NSString *)pwd
{
    [UserDefaultsUtils saveValue:pwd forKey:SYSTEM_LOGIN_PWD];
}

+ (NSString *)userId
{
    return [UserDefaultsUtils valueWithKey:SYSTEM_LOGIN_USERID];
}

+ (void)saveUserId:(NSString *)userId
{
    [UserDefaultsUtils saveValue:userId forKey:SYSTEM_LOGIN_USERID];

}

+ (void)saveUserInfo:(UserInfoModel *)infoModel
{
    [self saveTelPhone:infoModel.telephone];
    [self savePersonalizedSignature:infoModel.personalizedSignature];
    [self saveSex:infoModel.sex];
    [self saveIdcardNo:infoModel.idcardNo];
    [self saveNickName:infoModel.nickName];
    [self saveUsername:infoModel.username];
}

+ (void)removeUserInfo
{
    [self removeSex];
    [self removeIdcardNo];
    [self removeNickName];
    [self removeUsername];
    [self removePersonalizedSignature];
    [self removeTelPhone];
    [self removeToken];
    [self removeIsLogin];
}

+ (UserInfoModel *)userInfo
{
    UserInfoModel *model = [[UserInfoModel alloc] init];
    model.personalizedSignature = [self personalizedSignature];
    model.sex = [self sex];
    model.idcardNo = [self idcardNo];
    model.username = [self username];
    model.nickName = [self nickName];
    return model;
}

+ (BOOL)isLogin
{
    return [UserDefaultsUtils boolValueWithKey:SYSTEM_LOGIN_ISLOGIN];
}

+ (void)saveIsLogin:(BOOL)isLogin
{
    [UserDefaultsUtils saveBoolValue:isLogin withKey:SYSTEM_LOGIN_ISLOGIN];
}

+ (void)removeIsLogin
{
    [UserDefaultsUtils removeValueWthKey:SYSTEM_LOGIN_ISLOGIN];
}

@end
